<%--
  Created by IntelliJ IDEA.
  User: 86158
  Date: 2022/10/25
  Time: 11:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册</title>
    <link href="${pageContext.request.contextPath}/layui/css/layui.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>

    <style>
        * {
            margin: 0 auto;
            padding: 0;
        }

        #div1 {
            text-align: center;
            width: 500px;
            height: 400px;
            background-color: white;
        }

        #title {
            padding-bottom: 30px;
            color: #1e9fff;

        }

        .input1 {
            background-color: rgba(115, 189, 236, 0.78);
        }

        .icon {
            font-size: 30px;
            font-weight: bold;
            color: #1e9fff;
        }
    </style>
</head>
<body style="align-items: center;display: flex;">
<div id="div1" class="layui-main">
    <h1 id="title">添加职位</h1>
    <hr>
    <br>
    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/user/register" method="post">

        <div class="layui-form-item" style="margin-left: 50px">
            <label class="layui-form-label"><i class="layui-icon layui-icon-username icon"></i></label>
            <div class="layui-input-inline">
                <input type="text" name="name" required lay-verify="required" placeholder="请输入职位名称"
                       autocomplete="off" class="layui-input input1">
            </div>
        </div>
        <div class="layui-form-item" style="margin-left: 50px">
            <label class="layui-form-label"><i class="layui-icon layui-icon-user icon"></i></label>
            <div class="layui-input-inline">
                <textarea name="remark" required lay-verify="required" placeholder="请输入职位描述" class="layui-textarea input1"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="loginInfo">添加</button>
                    <button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
                </div>
            </div>
        </div>

    </form>
</div>

</body>
<script>
    //Demo
    layui.use(['form', 'jquery', 'layer','element'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        var element = layui.element;

        //提交
        form.on('submit(loginInfo)', function (data) {
            $.ajax({
                type: 'post',
                async: false,
                url: '${pageContext.request.contextPath}/job/addJob',
                contentType: "application/json",
                data: JSON.stringify(data.field),
                dataType: 'json',
                success: function (rs) {
                    if (rs == '1') {
                        layer.msg("该职位名称已经被使用", {icon: 2});
                    } else if (rs == '2') {
                        layer.msg("职位添加成功！", {icon:1});
                        $('#reset').trigger('click');
                    }

                }
            });
            return false;
        });

    });
</script>
</html>
